//package com.example.demo.redislock.service.impl;
//
//import com.example.demo.redislock.service.ITestRedLockService;
//import com.example.demo.redislock.support.DistributedRedisLock;
//import jodd.util.PropertiesUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.redisson.RedissonRedLock;
//import org.redisson.api.RLock;
//import org.redisson.api.RedissonClient;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.concurrent.TimeUnit;
//
///**
// * @author lys4134
// * @ClassName TestLockServiceImpl
// * @Date 2022/03/17 09:39:05
// * @Description TestLockServiceImpl
// * @Version 1.0
// **/
////@Service
//@Slf4j
//public class TestRedLockServiceImpl implements ITestRedLockService {
//
//    private final String CLOSE_ORDER_TASK_LOCK = "CLOSE_ORDER_TASK_LOCK";
//
//    @Autowired
//    private RedissonClient redissonClient;
//
//
//
//
//
//    /**
//     * 测试不释放锁
//     */
//    @Override
//    public void testRedLock() {
//        RLock lock1 = redissonClient.getLock("lock1");
////        RLock lock2 = redissonClient.getLock("lock2");
////        RLock lock3 = redissonClient.getLock("lock3");
////        RedissonRedLock lock = new RedissonRedLock(lock1, lock2, lock3);
////
////        boolean getLock = false;
////        try {
////            if(getLock = lock.tryLock(0,5, TimeUnit.SECONDS)){
////                log.info("Redisson获取到分布式锁:{},ThreadName:{}",CLOSE_ORDER_TASK_LOCK,Thread.currentThread().getName());
////                int hour = Integer.parseInt(PropertiesUtil.getProperty("close.order.task.time.hour","2"));
////                iOrderService.closeOrder(hour);
////            }else{
////                log.info("Redisson没有获取到分布式锁:{},ThreadName:{}",CLOSE_ORDER_TASK_LOCK,Thread.currentThread().getName());
////            }
////        } catch (InterruptedException e) {
////            log.error("Redisson分布式锁获取异常",e);
////        } finally {
////            if(!getLock){
////                return;
////            }
////            lock.unlock();
////            log.info("Redisson分布式锁释放锁");
////        }
//    }
//
//    /**
//     * 实际业务开发使用分布式锁的方式
//     */
//    @Override
//    public void post() {
//
//    }
//
//}
